package kt.com.bilin.coin.ui.fragment

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.bilin.coin.R
import com.flyco.tablayout.listener.OnTabSelectListener
import kotlinx.android.synthetic.main.fragment_mill.*
import kotlinx.android.synthetic.main.fragment_mill.stSegmentTabLayout
import kotlinx.android.synthetic.main.fragment_v2_mill.*
import kt.com.bilin.coin.ui.fragment.mill.MillResourceFragment
import kt.com.bilin.coin.ui.fragment.mill.MyMillManageFragment
import kt.com.bilin.coin.utils.FragmentChangeManager
import java.util.*

class MillFragment : BaseFragment(R.layout.fragment_v2_mill), OnTabSelectListener {
    private var mFragmentChangeManager: FragmentChangeManager? = null
    private val mTitles = arrayOf("我的矿机", "矿机资源")
    override fun initView(rootView: View?, savedInstanceState: Bundle?) {
        stSegmentTabLayout.setTabData(mTitles)
        stSegmentTabLayout.setOnTabSelectListener(this)
        val fragments = ArrayList<Fragment>()
        fragments.add(MyMillManageFragment())
        fragments.add(MillResourceFragment())
        mFragmentChangeManager = FragmentChangeManager(childFragmentManager, R.id.frameLayout, fragments)
        ivBack.setOnClickListener { activity?.finish() }
    }

    override fun onTabSelect(position: Int) {
        mFragmentChangeManager?.setFragments(position)
    }

    override fun onTabReselect(position: Int) {
    }

}